function creatTime(timestamp) {
  if(!timestamp) return
   var date = new Date(
     parseInt(timestamp.replace("/Date(", "").replace(")/", ""), 10)
   );
   var Y = date.getFullYear() + "-";
   var M =
     (date.getMonth() + 1 < 10 ?
       "0" + (date.getMonth() + 1) :
       date.getMonth() + 1) + "";
   var D =
     (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
   var h =
     (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
   var m =
     date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
   var s =
     date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
   return Y + M + "-" + D + h + m;
 }

 function recTime(time1, time2 = 0) {
   var date = new Date(
     parseInt(time1.replace("/Date(", "").replace(")/", ""), 10)
   );
   // console.log(date.getTime())
   if (time2) {
     var ms = date.getTime() + time2 * 1000;
   } else {
     var ms = date.getTime();
   }

   return getDateStr(ms);
 }

 function getDateStr(ms) {
   if (ms) {
     var date = new Date(ms);
   } else {
     var date = new Date();
   }
   var year = date.getFullYear();
   var month = date.getMonth() + 1;
   var day = date.getDate();
   var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
   var minute =
     date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
   var second =
     date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
   var currentTime =
     year + "-" + month + "-" + day + "  " + hour + ":" + minute;
   // +
   // ":" +
   // second;
   return currentTime;
 }
 //时间比较
 function comptime(nowDate, lastDate) {
   var a = (Date.parse(nowDate) - Date.parse(lastDate)) / 3600 / 1000;
   if (a < 0) {
     return "lastDate";
   } else if (a >= 0) {
     return "nowDate";
   }
 }

 export  {
   creatTime,
   recTime,
   getDateStr,
   comptime
 }
